/**
 * Project Name:spring-cloud-pilot File Name:ClassPathFileSystemWatcher.java Package Name:org.spring.cloud.pilot.jar
 * Date:2019年10月25日上午11:21:36 Copyright (c) 2019, dengqian37@126.com All Rights Reserved.
 *
 */

package org.spring.cloud.pilot.jar;

import org.spring.cloud.pilot.filewatch.FileSystemWatcher;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * ClassName:ClassPathFileSystemWatcher <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON. <br/>
 * Date: 2019年10月25日 上午11:21:36 <br/>
 * 
 * @author dengqian
 * @version
 * @since JDK 1.8
 * @see
 */
public class ClassPathFileSystemWatcher implements InitializingBean, DisposableBean, ApplicationContextAware {
    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

        this.applicationContext = applicationContext;

    }

    @Override
    public void destroy() throws Exception {

        // TODO Auto-generated method stub

    }

    @Override
    public void afterPropertiesSet() throws Exception {

        FileSystemWatcher watcher = new FileSystemWatcher(false, 3000, 500);
        watcher.addListener(new ClassPathFileChangeListener(applicationContext));
        watcher.start();

    }

}
